import 'package:json_annotation/json_annotation.dart';

part 'message.g.dart';

@JsonSerializable()
class MessageModel {
  String addTime;

  String title;

  String rangeTime;

  String? applicant;

  MessageStatusEnum status;

  MessageTypeEnum type;

  MessageModel(
      {required this.title,
      required this.rangeTime,
      required this.addTime,
      required this.status,
      required this.type,
      this.applicant});

  factory MessageModel.fromJson(Map<String, dynamic> json) =>
      _$MessageModelFromJson(json);

  Map<String, dynamic> toJson() => _$MessageModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

enum MessageStatusEnum {
  read(1, '已读'),
  unread(2, '未读');

  final int value;
  final String label;

  const MessageStatusEnum(this.value, this.label);
}

enum MessageTypeEnum {
  upkeepTask(1, '保养任务'),
  faultAudit(2, '故障审核'),
  spareReceiveAudit(3, '备件领用审核'),
  repairOrder(4, '维修工单'),
  inspectionTask(5, '巡检任务');

  final int value;
  final String label;

  const MessageTypeEnum(this.value, this.label);
}
